use fifty_tone::generate_random_sequence;
use std::collections::HashMap;
use std::env;
use fifty_tone::UnExpectedError;
use std::result::Result;
use std::fs::read_to_string;

fn main()->Result<(),UnExpectedError> {
    let args: Vec<String> = env::args().collect();
    let s;
    if !(args.len()==1 || args.len()==2) {
        return Err(UnExpectedError::ArgumentsNumsErr)
    }

    if args.len()==1 {
        s="あ い う え お
           ".to_string();
    } else {
        s=read_to_string(&args[1])?;
    }

    let fifty_tones:Vec<char>=s.chars().filter(|c| !c.is_whitespace() ).collect();
    let keys_tones: HashMap<usize, &char> = (0..fifty_tones.len()).zip(fifty_tones.iter()).collect();
    generate_random_sequence(&keys_tones);
    Ok(())
}

